package org.liaohailong.helloworld;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import org.liaohailong.helloworld.fragment.MainFragment;
import org.liaohailong.helloworld.fragment.SecondFragment;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.fl_container, new MainFragment(), "MainFragment");
        ft.addToBackStack("MainFragment");
        ft.commit();

        ft = fm.beginTransaction();
        ft.replace(R.id.fl_container, new SecondFragment(), "SecondFragment");
        ft.commit();
    }
}